classdef UtilityQuasiLinear < handle
% UTILITYQUASILINEAR implements quasi-linear utility

    properties
        epsilon % labor supply elasticity
    end

    methods
        function self = UtilityQuasiLinear(varargin)
            p = inputParser;
            p.KeepUnmatched = true;
            p.addParameter('epsilon', [], @(x) x>0)
            p.parse(varargin{:});
            self.epsilon = p.Results.epsilon;
            assert(~isempty(self.epsilon),'need to provide epsilon')
        end

        function out = l(self,w,xi)
        % labor supply as function of the net-wage w
            out = (xi.*w).^self.epsilon;
        end
        
        function out = utility(self,c,l,xi)
        % utility function
            out = c-1/xi.*l.^(1+1/self.epsilon)./(1+1/self.epsilon);
        end

        function out = dUdl(self,l,xi)
            out = -1/xi.*l.^(1/self.epsilon);
        end

        function out = mtax(self,l,w,xi)
            out = 1+self.dUdl(l,xi)./w;
        end

        function out = udot(self,l,w,xi)
            out = -self.dUdl(l,xi).*l./w;
        end

        function out = c(self,V,l,xi)
        % consumption as function of indirect utility V and labor
        % supply l
            out = V+1/xi.*l.^(1+1/self.epsilon)./(1+1/self.epsilon);
        end
        
    end

end